#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
****************************************************
Project:python
Filename: alipan.py
Author:银河
Create: 2025/10/11 上午9:12 
Notes:阿里云盘签到提醒   https://api.shanhe.kim/  https://www.alipan.com/
cron: 5 10 * * *
***************************************************
'''
import time
import os
import requests

class AliPan:
    def __init__(self):
        self.token = dict(os.environ)['aliToken']
        # self.token = '0a7b0ccb5299498ca110c26d2c7a20d0'

    def tijiao(self):
        '''提交任务'''
        url = "http://shanhe.kim/api/ali/aliv2.php?name=673905030&token={}&s=write"
        res = requests.get(url=url.format(self.token)).json()
        if res['code'] != 200:
            self.weixin(res['message'])
            return
        time.sleep(6)
        self.tixing()

    def tixing(self):
        url = "http://shanhe.kim/api/ali/ali.php?token={}"
        res = requests.get(url=url.format(self.token)).json()
        if res['code'] == 200:
            content = f'''
                        <div>签到状态：{res['message']['message']}</div>
                        <div>签到天数：{res['message']['signInCount']}</div>
                        <hr>
                        '''
            self.weixin(content)
            return
        elif res['code'] == 500:
            self.weixin(res['error'])
            return
        else:
            print("其他错误")
            return

    def weixin(self,content):
        data = {
            "title": "阿里云盘签到提醒",
            "content": content
        }
        res = requests.post(url="http://yh.xuenn.cn/api/weixin/", data=data)
        if res.status_code == 200:
            print('pushplus推送成功')
            return 'pushplus推送成功'
        else:
            print('系统错误，pushplus推送失败')
            return '系统错误，pushplus推送失败'
    def main(self):
        self.tijiao()

if __name__ == '__main__':
    AliPan().main()
